home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / oocs / frmserve.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-06  |  3.0 KB  |  93 lines

  1. VERSION 5.00
  2. Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
  3. Begin VB.Form frmServer 
  4.    BorderStyle     =   4  'Fixed ToolWindow
  5.    Caption         =   "Server"
  6.    ClientHeight    =   570
  7.    ClientLeft      =   8010
  8.    ClientTop       =   5190
  9.    ClientWidth     =   4680
  10.    Icon            =   "frmServer.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   570
  15.    ScaleWidth      =   4680
  16.    ShowInTaskbar   =   0   'False
  17.    Begin VB.CommandButton cmdExit 
  18.       Caption         =   "&Exit"
  19.       Height          =   375
  20.       Left            =   3720
  21.       TabIndex        =   0
  22.       Top             =   120
  23.       Width           =   855
  24.    End
  25.    Begin MSWinsockLib.Winsock tcpServer 
  26.       Left            =   4080
  27.       Top             =   2160
  28.       _ExtentX        =   741
  29.       _ExtentY        =   741
  30.       _Version        =   393216
  31.    End
  32.    Begin VB.Label lblCReq 
  33.       BorderStyle     =   1  'Fixed Single
  34.       Height          =   255
  35.       Left            =   120
  36.       TabIndex        =   1
  37.       Top             =   160
  38.       Width           =   3495
  39.    End
  40. Attribute VB_Name = "frmServer"
  41. Attribute VB_GlobalNameSpace = False
  42. Attribute VB_Creatable = False
  43. Attribute VB_PredeclaredId = True
  44. Attribute VB_Exposed = False
  45. Option Explicit
  46. Private WithEvents RemoteServer As cServerActions
  47. Attribute RemoteServer.VB_VarHelpID = -1
  48. Private Sub RemoteServer_ConnectionClosed()
  49.     Form_Load      ' reload the form
  50.     Set RemoteServer = Nothing
  51.     Set Server_ = Nothing
  52. End Sub
  53. Private Sub RemoteServer_RequestedID(Accepted As Boolean)
  54.     If Accepted Then
  55.        'Set the connection variable
  56.        bInConnection = True
  57.        SendData "Accepted,"
  58.        StatusReport "Connection Made"
  59.        Exit Sub
  60.     End If
  61.     ' notify client there was a connection error
  62.     SendData "Request_Error, There was an error with the RequestID"
  63. End Sub
  64. Private Sub tcpServer_Close()
  65.     Server_.Closed tcpServer
  66.     StatusReport "Connection Terminated"
  67. End Sub
  68. Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
  69.     If bInConnection Then Exit Sub      'if connected continue, don't accept
  70.     ' re create and reference the objects, since they were
  71.     ' destroyed earlier when the connection was terminated
  72.     Set Server_ = New cServerActions
  73.     Set RemoteServer = Server_
  74.     ' send in the connection request
  75.     Server_.ConnectReq requestID, tcpServer
  76. End Sub
  77. Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
  78.     Dim sIncoming As String
  79.     tcpServer.GetData sIncoming
  80.     '--- send the data to be evaluated
  81.     Server_.HandleIncomingData sIncoming, tcpServer, frmServer
  82. End Sub
  83. Private Sub cmdExit_Click()
  84.     Unload Me
  85. End Sub
  86. Private Sub Form_Load()
  87.     On Error GoTo GetOut
  88.     Server_.InitTCP 333, tcpServer   ' initialze winsock to listen
  89.     bInConnection = False
  90. GetOut:
  91.     Exit Sub
  92. End Sub
  93.